import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
import { IModelData } from "../../../../extensions/phoenix-plugin-client/assets/core/interface/iModelData";
import * as proto from "../protoc/ts/proto_app.js";

/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-03-21 14:02:33
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2024-08-09 18:09:46
 * @FilePath: \dwys_web\assets\script\phoenix\models\avatar.model.ts
 * @Description: 
 */
export class AvatarModel implements IModelData {
    gamePoint:number;
    carrot:number;
    roomInfo:Map<number, proto.Iroom_info>;
    roomPmtInfo:Map<number, Map<number, proto.Iroom_pmt_info>>;
    minuteCarrot: number;
    constructor(){
        this.gamePoint = 0;
        this.carrot = 0;
        this.minuteCarrot = 0;
        this.roomInfo = new Map();
        this.roomPmtInfo = new Map();
    }
    SerializeData(): string {
        return JSON.stringify(this);
    }
    Deserialization(data: string): void {
        // let d = JSON.parse(data);
        // console.log(d);
    }

    public getGamePoint():number{
        return this.gamePoint;
    }

    public getCarrot():number{
        return this.carrot;
    }

    public setGamePoint(point:number):void{
        this.gamePoint = point;
    }

    public setCarrot(carrot:number):void{
        this.carrot = carrot;
    }

    public getMinuteCarrot():number{
        return this.minuteCarrot;
    }

    public setMinuteCarrot(minuteCarrot:number):void{
        this.minuteCarrot = minuteCarrot;
    }
    
    public getRoomInfoMap():Map<number, proto.Iroom_info>{
        return this.roomInfo;
    }

    public getRoomInfo(roomId:number):proto.Iroom_info | undefined{
        return this.roomInfo.get(roomId);
    }

    public setRoomInfo(roomInfo:proto.Iroom_info):void{
        this.roomInfo.set(roomInfo.roomId!, roomInfo);
    }

    public getRoomPmtInfoMap(roomId:number):Map<number, proto.Iroom_pmt_info> |  undefined{
        return this.roomPmtInfo.get(roomId);
    }

    public getRoomPmtInfo(roomId:number, pmtId:number):proto.Iroom_pmt_info | undefined{
        let roomPmtInfo = this.getRoomPmtInfoMap(roomId);
        if(roomPmtInfo){
            return roomPmtInfo.get(pmtId);
        }
        return undefined;
    }

    public setRoomPmtInfo(roomId:number, roomPmtInfo:proto.Iroom_pmt_info):void{
        let roomPmtInfoMap = this.getRoomPmtInfoMap(roomId);
        if(roomPmtInfoMap){
            roomPmtInfoMap.set(roomPmtInfo.pmtId!, roomPmtInfo);
        }else{
            roomPmtInfoMap = new Map();
            roomPmtInfoMap.set(roomPmtInfo.pmtId!, roomPmtInfo)
        }
    }
}